//内部类

class OuterClass {
    public int data1 = 1;
    public static int data2 = 2;
    private int data3 = 3;

    class InnerClass {
        public int data1 = 111;
        public int data4 = 4;
        public static final int data5 = 5;//编译的时候就已经确定
        private int data6 =5;

        public void test() {
            System.out.println("InnerClass::test()");
            System.out.println(OuterClass.this.data1);
            System.out.println(data2);
            System.out.println(data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }

    public void test() {
        System.out.println("OuterClass::test()");
    }
}

class Out {
    public int data1 = 10;
    public static int data2 = 2;
    private int data3 = 3;

    //静态内部类
    static class InnerClass {
        public int data4 = 4;
        public static int data5 = 5;
        private int data6 = 6;

        public void test() {
            System.out.println("InnerClass::test()");
            Out out = new Out();
            System.out.println(out.data1);
            System.out.println(data2);
            System.out.println(out.data3);
            System.out.println(data4);
            System.out.println(data5);
            System.out.println(data6);
        }
    }

    public void test() {
        System.out.println("OuterClass::test()");
    }
}

interface IA {
    void test();
}


public class Test2 {
    public static void main(String[] args) {
        IA a = new IA(){
            @Override
            public void test() {
                System.out.println("这是重写了接口的方法！");
            }
        };
        a.test();
    }

    public static void main2(String[] args) {
        Out.InnerClass innerClass = new Out.InnerClass();
        innerClass.test();
    }

    public static void main1(String[] args) {
        OuterClass outerClass = new OuterClass();
        OuterClass.InnerClass innerClass = outerClass.new InnerClass();
        System.out.println(OuterClass.InnerClass.data5);

        innerClass.test();
        outerClass.test();
    }
}







